//
//  JuSwiftBasics.swift
//  JuSwift
//
//  Created by 朱天伟(平安租赁事业群(汽融商用车)信息科技部科技三团队) on 2022/11/25.
//  Copyright © 2022 Juvid. All rights reserved.
//

import Foundation
import UIKit

class JuHelloSwift  {
    
    lazy var testDic: NSDictionary = {
        return NSDictionary.init()
    }()
    func juTest()  {
        juSimple()
        juArr()
        juFor()
        juDic()
        juNSArr()
        
    }
    func juSimple() {
        let myConstant = 42
        var myVariable : CGFloat = 70
        myVariable=70
        //显示转换
        let lable = "the world is"
        let width = 12
        let widthLable = lable + String(width)

        let apple = "zhu"
        let orange = "tian wei"
        let fullName = "my name is \(apple + orange)"
        
        //默认值
        let nickName: String? = "juvid"
        let fullNames: String = "zhu tian wei"
        let infoMalGreeting = "Hi \(nickName ?? fullNames)"
                
        var str = "Hello, playground"
        let myConstant1 : Int = 44
        
        var optionalName: String? = "John Appleseed"
        var greeting = "Hello!"
        if  optionalName != nil {
            greeting = "Hello, \(String(describing: optionalName))"
        }
        let sideLength = optionalName

        let name = "jute"
   

        switch name {
        case "jute":
            print("jute")
        case "juvid":
            print("juvid")
        default:
            print("none")
        }
        
    }
    func juFor()  {
        let arr1 = ["123","234","345","456"]
        NSLog("%@", arr1)
        for index in 1...5 {
            if index == 0 {
                NSLog("第一个")
            }
            NSLog("第 %@ 个", String(index))
        }
    }
    
    func juDic()  {
        let interestingNumbers = [
            "Prime":[2,3,4,5,6],
            "Fibonacci":[32,54,65,76],
            "Square":[5,6,7,9]
        ]
    }
    
    func juArr()  {
        
        var myCount = ["数组","第二个"]
        var copyCout = myCount
        copyCout[0]="juvid"
        
        let my = "my cout \(myCount)"
        let withLable =  String(describing: myCount)
        
        var emptyArray = [NSInteger]()
        emptyArray=[123,2345]

    }
    
    func juNSArr()  {
        
        let arr = NSMutableArray.init()
        arr.add("234354");
        NSLog("%@", arr);
        
        let newNames = arr
        newNames[0]="12345"
        newNames.add("234567")
        
        for arrStr in newNames {
            print("Hello, \(arrStr)!")
        }
        
        var arr2 = [AnyObject]() //创建一个空数组
        arr2.append(1 as AnyObject)
        arr2.append("test" as AnyObject)
        arr2.append(NSNumber(value: 4.0))
        NSLog("%@", arr2)
    }
}
